<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                    	<!--  <input type="hidden" id="category" name="category" value="059607FBE17D43FCB18C8BA9179C1681" />-->
                     <input type="hidden" id="id" name="id" th:value="${info?.id}" />
                        <div class="form-group">
                            <span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>姓名：</label>
                            </span>
                            <div class="col-sm-8">
                                <input readonly id="name" name="name" th:value="${info?.name}" class="form-control" type="text" maxlength="100">
                            </div>
                        </div>

						<div class="form-group">
                            <span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>日期：</label>
                            </span>
                            <div class="col-sm-8">
                                <input readonly id="eTime" name="eTime" th:value="${info?.eTime}" class="form-control" type="text" maxlength="100">
                            </div>
                        </div>
                        
                        <!--  <div class="form-group">
							<label class="col-sm-3 control-label ">是否置顶：</label>
							<div class="col-lg-8 col-sm-8 col-xs-8">
								<select disabled="disabled"  id="top" name="top" class="form-control">
									<option value ="2">不置顶</option>
  									<option value ="1">置顶</option>
								</select>
							</div>
						</div>
                        -->
                        <div class="form-group">
                            <span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>描述：</label>
                            </span>
                            <div class="col-sm-8">
                                <input readonly id="describe" name="describe" th:value="${info?.describe}" class="form-control"  type="text"  >
                            </div>
                        </div>
						<div class="form-group">
                            <span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>结果：</label>
                            </span>
                            <div class="col-sm-8">
                                <input readonly id="result" name="result" th:value="${info?.result}" class="form-control" type="text" maxlength="100">
                            </div>
                        </div>
						<div class="form-group">
                            <span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>地址：</label>
                            </span>
                            <div class="col-sm-8">
                                <input readonly id="addr" name="addr" th:value="${info?.addr}" class="form-control" type="text" maxlength="100">
                            </div>
                        </div>
                        
                        

                        <div class="form-group">
                            <div align="center"> 
<!--                            <a class="btn btn-primary btn-sm " onclick="goBack()"><i class="fa fa-arrow-circle-left">返回</i></a> -->
<!-- 		                    <button type="submit" class="btn btn-primary">提交</button> -->
	                        </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/js/layui.js"></script>

<script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/ueditor/ueditor.all.js"></script>
<script type="text/javascript" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="/js/plugins/layer/layer.min.js"></script>
<script type="text/javascript" th:inline="javascript">
    
    var files; 
    layui.use('upload', function () {
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#test1', //绑定元素
            auto:false, 
            acceptMime: 'image/*',
            size: 1000,
            multiple:false,
            number:1,
            accept: 'images',
            choose: function(obj){  
                //将每次选择的文件追加到文件队列 
                files = obj.pushFile();  
                //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
                obj.preview(function(index, file, result){
                  $('#demo2').attr('src', result); //图片链接（base64） 
                  $('#hasOne').val(file.name);
                  $('#hasOne-error').attr("style","display: none;");
                  
               });
            }
        });
    });
    
    function update() {
		var form = new FormData();  
    	for(i in files){
			form.set("file",files[i]);
		}
		form.append("name",$("#name").val()); 
		form.append('age',$("#age").val());
		form.append('addr',$("#addr").val());
		form.append('sex',$("#sex").val());
		//form.append('sort',$("#sort").val());
		//form.append('content',ue.getContent());
		form.append('id',$("#id").val());
		$.ajax({
			type : "POST",
			url : prefix+"/save",
			contentType:false,
			processData :false,
			data : form,
			async : false,
			error : function(request) {
				parent.layer.alert("Connection error");
			},
			success : function(data) {
				if (data.code == 0) {
					parent.layer.msg("操作成功");
					parent.location.reload();
					var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
					parent.layer.close(index);

				} else {
					parent.layer.alert(data.msg)
				}

			}
		}); 
	}
</script>

<script type="text/javascript">
var prefix = "/persion/manage"
	$().ready(function(){ 
		//selectedHtml("classify","F642C63D392B46E08DB92FA5250FCC6D", $("#classifyValue").val());
		validateRule(); 
	});

	$.validator.setDefaults({
		submitHandler : function() {
			update();
		}
	}); 

	function validateRule() { 
	    var icon = "<i class='fa fa-times-circle'></i> ";
	    $("#signupForm").validate({
	    	rules : {
	    		name : {
	    			required : true
	            },
	            eTime : {
	            	required : true
	            }, 
	            addr : {
	            	required : true
	            }, 
	            result: {
	            	required : true,

	            }, 
	            describe : {
	            	required : true
	            } 
	        },
	        messages : {
	        	name : {
	        		required : icon + "姓名"
	            },
	            eTime : {
	            	required : icon + "年龄"
	            }, 
	            addr : {
	            	required : icon + "性别"
	            }, 
	            result: {
	            	required : icon + "地址",

	            },
	            describe:{
	            	required : icon + "生日"
	            }
	        }
	    })
	}

	//字典
	var selectedHtml = function(selctId,gValue,hxId){
	    $("#"+selctId).empty();
	    $.ajax({
	        cache : true,
	        type : "GET",
	        url : "/common/sysDict/listByGroup",
	        data : {"gValue":gValue},
	        async : false,
	        error : function(request) {
	            alertMsg("通信出错!");
	        },
	        success : function(data) {
	            if (data.code == 0) {
	                var arr = data.data;
	                var option = "<option value=''>-请选择-</option>";
	                if(hxId == ""){
	                    option = "<option value='' selected='selected'>-请选择-</option>";
	                }else{
	                    option = "<option value='' >-请选择-</option>";
	                }
	                $("#"+selctId).append(option);
	                $.each(arr,function(index,obj){
	                    if(obj.value != null){
	                        var htmlRes = "";
	                        if(obj.id == hxId){
	                            htmlRes = "<option value='"+obj.id+"' selected='selected'>"+obj.name+"</option>";
	                        }else{
	                            htmlRes = "<option value='"+obj.id+"'>"+obj.name+"</option>";
	                        }
	                        $("#"+selctId).append(htmlRes);
	                    }
	                });
	            } else {
	                alertMsg(data.msg)
	            }
	        }
	    });
	};
</script>
</body>
</html>
